{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据概要\n",
    "\n",
    "- 头部数据、尾部数据\n",
    "- 索引、列名\n",
    "- 查看数值（array）\n",
    "- 查看统计摘要\n",
    "\n",
    "## 数据查询\n",
    "\n",
    "- 列数据\n",
    "- 行数据\n",
    "- 行列切片\n",
    "- 按值筛选\n",
    "- 按条件筛选（布尔值）\n",
    "\n",
    "## 其他\n",
    "\n",
    "- 转置\n",
    "- 排序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2021-01-31', '2021-02-28', '2021-03-31', '2021-04-30',\n",
       "               '2021-05-31', '2021-06-30', '2021-07-31', '2021-08-31',\n",
       "               '2021-09-30', '2021-10-31', '2021-11-30', '2021-12-31',\n",
       "               '2022-01-31', '2022-02-28', '2022-03-31', '2022-04-30',\n",
       "               '2022-05-31', '2022-06-30', '2022-07-31', '2022-08-31',\n",
       "               '2022-09-30', '2022-10-31', '2022-11-30', '2022-12-31',\n",
       "               '2023-01-31', '2023-02-28', '2023-03-31', '2023-04-30',\n",
       "               '2023-05-31', '2023-06-30'],\n",
       "              dtype='datetime64[ns]', freq='M')"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 创建一个dataframe：带时间戳的价格数据\n",
    "dates = pd.date_range('20210101',periods=30,freq='M')\n",
    "dates"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-31</th>\n",
       "      <td>0.613732</td>\n",
       "      <td>0.909638</td>\n",
       "      <td>0.047108</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-02-28</th>\n",
       "      <td>0.358820</td>\n",
       "      <td>0.721158</td>\n",
       "      <td>0.330718</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-03-31</th>\n",
       "      <td>0.731428</td>\n",
       "      <td>0.306866</td>\n",
       "      <td>0.641701</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-04-30</th>\n",
       "      <td>0.126878</td>\n",
       "      <td>0.845668</td>\n",
       "      <td>0.247112</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-05-31</th>\n",
       "      <td>0.032277</td>\n",
       "      <td>0.024703</td>\n",
       "      <td>0.628470</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-06-30</th>\n",
       "      <td>0.837586</td>\n",
       "      <td>0.993431</td>\n",
       "      <td>0.012104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-07-31</th>\n",
       "      <td>0.018186</td>\n",
       "      <td>0.957074</td>\n",
       "      <td>0.830343</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-08-31</th>\n",
       "      <td>0.573957</td>\n",
       "      <td>0.071518</td>\n",
       "      <td>0.292554</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>0.216704</td>\n",
       "      <td>0.556329</td>\n",
       "      <td>0.114322</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-31</th>\n",
       "      <td>0.415388</td>\n",
       "      <td>0.386422</td>\n",
       "      <td>0.005755</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-11-30</th>\n",
       "      <td>0.944264</td>\n",
       "      <td>0.917082</td>\n",
       "      <td>0.635947</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-31</th>\n",
       "      <td>0.917223</td>\n",
       "      <td>0.187567</td>\n",
       "      <td>0.787683</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-31</th>\n",
       "      <td>0.612247</td>\n",
       "      <td>0.249439</td>\n",
       "      <td>0.801120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-28</th>\n",
       "      <td>0.197643</td>\n",
       "      <td>0.851493</td>\n",
       "      <td>0.416230</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-31</th>\n",
       "      <td>0.995394</td>\n",
       "      <td>0.687213</td>\n",
       "      <td>0.023632</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-04-30</th>\n",
       "      <td>0.938512</td>\n",
       "      <td>0.158694</td>\n",
       "      <td>0.728262</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-05-31</th>\n",
       "      <td>0.539542</td>\n",
       "      <td>0.238714</td>\n",
       "      <td>0.645599</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-06-30</th>\n",
       "      <td>0.619338</td>\n",
       "      <td>0.487312</td>\n",
       "      <td>0.310921</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-07-31</th>\n",
       "      <td>0.405686</td>\n",
       "      <td>0.107931</td>\n",
       "      <td>0.853166</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-31</th>\n",
       "      <td>0.681796</td>\n",
       "      <td>0.319507</td>\n",
       "      <td>0.368438</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-30</th>\n",
       "      <td>0.872917</td>\n",
       "      <td>0.713191</td>\n",
       "      <td>0.059227</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-31</th>\n",
       "      <td>0.254922</td>\n",
       "      <td>0.321541</td>\n",
       "      <td>0.314493</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-30</th>\n",
       "      <td>0.277941</td>\n",
       "      <td>0.437114</td>\n",
       "      <td>0.408588</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-31</th>\n",
       "      <td>0.731630</td>\n",
       "      <td>0.278186</td>\n",
       "      <td>0.803909</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-01-31</th>\n",
       "      <td>0.508458</td>\n",
       "      <td>0.600408</td>\n",
       "      <td>0.372008</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-02-28</th>\n",
       "      <td>0.206506</td>\n",
       "      <td>0.467584</td>\n",
       "      <td>0.637022</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-03-31</th>\n",
       "      <td>0.753834</td>\n",
       "      <td>0.661845</td>\n",
       "      <td>0.146919</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-04-30</th>\n",
       "      <td>0.003151</td>\n",
       "      <td>0.062338</td>\n",
       "      <td>0.370141</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-05-31</th>\n",
       "      <td>0.957500</td>\n",
       "      <td>0.318095</td>\n",
       "      <td>0.969816</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-06-30</th>\n",
       "      <td>0.565919</td>\n",
       "      <td>0.889526</td>\n",
       "      <td>0.194806</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C\n",
       "2021-01-31  0.613732  0.909638  0.047108\n",
       "2021-02-28  0.358820  0.721158  0.330718\n",
       "2021-03-31  0.731428  0.306866  0.641701\n",
       "2021-04-30  0.126878  0.845668  0.247112\n",
       "2021-05-31  0.032277  0.024703  0.628470\n",
       "2021-06-30  0.837586  0.993431  0.012104\n",
       "2021-07-31  0.018186  0.957074  0.830343\n",
       "2021-08-31  0.573957  0.071518  0.292554\n",
       "2021-09-30  0.216704  0.556329  0.114322\n",
       "2021-10-31  0.415388  0.386422  0.005755\n",
       "2021-11-30  0.944264  0.917082  0.635947\n",
       "2021-12-31  0.917223  0.187567  0.787683\n",
       "2022-01-31  0.612247  0.249439  0.801120\n",
       "2022-02-28  0.197643  0.851493  0.416230\n",
       "2022-03-31  0.995394  0.687213  0.023632\n",
       "2022-04-30  0.938512  0.158694  0.728262\n",
       "2022-05-31  0.539542  0.238714  0.645599\n",
       "2022-06-30  0.619338  0.487312  0.310921\n",
       "2022-07-31  0.405686  0.107931  0.853166\n",
       "2022-08-31  0.681796  0.319507  0.368438\n",
       "2022-09-30  0.872917  0.713191  0.059227\n",
       "2022-10-31  0.254922  0.321541  0.314493\n",
       "2022-11-30  0.277941  0.437114  0.408588\n",
       "2022-12-31  0.731630  0.278186  0.803909\n",
       "2023-01-31  0.508458  0.600408  0.372008\n",
       "2023-02-28  0.206506  0.467584  0.637022\n",
       "2023-03-31  0.753834  0.661845  0.146919\n",
       "2023-04-30  0.003151  0.062338  0.370141\n",
       "2023-05-31  0.957500  0.318095  0.969816\n",
       "2023-06-30  0.565919  0.889526  0.194806"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pd.DataFrame(np.random.rand(30,3), columns=list('ABC'),index=dates)\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-31</th>\n",
       "      <td>0.613732</td>\n",
       "      <td>0.909638</td>\n",
       "      <td>0.047108</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-02-28</th>\n",
       "      <td>0.358820</td>\n",
       "      <td>0.721158</td>\n",
       "      <td>0.330718</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-03-31</th>\n",
       "      <td>0.731428</td>\n",
       "      <td>0.306866</td>\n",
       "      <td>0.641701</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-04-30</th>\n",
       "      <td>0.126878</td>\n",
       "      <td>0.845668</td>\n",
       "      <td>0.247112</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-05-31</th>\n",
       "      <td>0.032277</td>\n",
       "      <td>0.024703</td>\n",
       "      <td>0.628470</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C\n",
       "2021-01-31  0.613732  0.909638  0.047108\n",
       "2021-02-28  0.358820  0.721158  0.330718\n",
       "2021-03-31  0.731428  0.306866  0.641701\n",
       "2021-04-30  0.126878  0.845668  0.247112\n",
       "2021-05-31  0.032277  0.024703  0.628470"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 头部数据、尾部数据\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-31</th>\n",
       "      <td>0.613732</td>\n",
       "      <td>0.909638</td>\n",
       "      <td>0.047108</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-02-28</th>\n",
       "      <td>0.358820</td>\n",
       "      <td>0.721158</td>\n",
       "      <td>0.330718</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-03-31</th>\n",
       "      <td>0.731428</td>\n",
       "      <td>0.306866</td>\n",
       "      <td>0.641701</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C\n",
       "2021-01-31  0.613732  0.909638  0.047108\n",
       "2021-02-28  0.358820  0.721158  0.330718\n",
       "2021-03-31  0.731428  0.306866  0.641701"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2023-02-28</th>\n",
       "      <td>0.206506</td>\n",
       "      <td>0.467584</td>\n",
       "      <td>0.637022</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-03-31</th>\n",
       "      <td>0.753834</td>\n",
       "      <td>0.661845</td>\n",
       "      <td>0.146919</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-04-30</th>\n",
       "      <td>0.003151</td>\n",
       "      <td>0.062338</td>\n",
       "      <td>0.370141</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-05-31</th>\n",
       "      <td>0.957500</td>\n",
       "      <td>0.318095</td>\n",
       "      <td>0.969816</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-06-30</th>\n",
       "      <td>0.565919</td>\n",
       "      <td>0.889526</td>\n",
       "      <td>0.194806</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C\n",
       "2023-02-28  0.206506  0.467584  0.637022\n",
       "2023-03-31  0.753834  0.661845  0.146919\n",
       "2023-04-30  0.003151  0.062338  0.370141\n",
       "2023-05-31  0.957500  0.318095  0.969816\n",
       "2023-06-30  0.565919  0.889526  0.194806"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.tail(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2021-01-31', '2021-02-28', '2021-03-31', '2021-04-30',\n",
       "               '2021-05-31', '2021-06-30', '2021-07-31', '2021-08-31',\n",
       "               '2021-09-30', '2021-10-31', '2021-11-30', '2021-12-31',\n",
       "               '2022-01-31', '2022-02-28', '2022-03-31', '2022-04-30',\n",
       "               '2022-05-31', '2022-06-30', '2022-07-31', '2022-08-31',\n",
       "               '2022-09-30', '2022-10-31', '2022-11-30', '2022-12-31',\n",
       "               '2023-01-31', '2023-02-28', '2023-03-31', '2023-04-30',\n",
       "               '2023-05-31', '2023-06-30'],\n",
       "              dtype='datetime64[ns]', freq='M')"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 索引、列名\n",
    "data.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['A', 'B', 'C'], dtype='object')"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.61373195, 0.90963794, 0.04710758],\n",
       "       [0.35881962, 0.72115783, 0.33071757],\n",
       "       [0.73142831, 0.30686638, 0.64170137],\n",
       "       [0.12687756, 0.84566761, 0.24711196],\n",
       "       [0.03227691, 0.02470314, 0.62847021],\n",
       "       [0.83758571, 0.99343088, 0.01210409],\n",
       "       [0.01818627, 0.95707384, 0.83034284],\n",
       "       [0.57395734, 0.07151762, 0.29255366],\n",
       "       [0.21670393, 0.55632854, 0.11432171],\n",
       "       [0.41538834, 0.3864216 , 0.00575529],\n",
       "       [0.94426393, 0.91708207, 0.63594728],\n",
       "       [0.91722309, 0.18756697, 0.78768256],\n",
       "       [0.6122467 , 0.24943888, 0.80112047],\n",
       "       [0.19764291, 0.85149261, 0.41622985],\n",
       "       [0.99539443, 0.68721255, 0.02363179],\n",
       "       [0.93851187, 0.15869429, 0.72826176],\n",
       "       [0.5395422 , 0.2387144 , 0.64559874],\n",
       "       [0.61933839, 0.48731224, 0.31092051],\n",
       "       [0.40568556, 0.10793083, 0.85316599],\n",
       "       [0.68179605, 0.31950728, 0.3684378 ],\n",
       "       [0.8729166 , 0.71319064, 0.05922718],\n",
       "       [0.25492159, 0.32154084, 0.3144932 ],\n",
       "       [0.27794113, 0.43711427, 0.40858835],\n",
       "       [0.73163031, 0.27818623, 0.80390927],\n",
       "       [0.50845756, 0.60040759, 0.37200829],\n",
       "       [0.20650553, 0.46758365, 0.6370221 ],\n",
       "       [0.75383435, 0.66184544, 0.14691941],\n",
       "       [0.00315055, 0.06233762, 0.37014107],\n",
       "       [0.9574998 , 0.31809475, 0.96981625],\n",
       "       [0.56591867, 0.88952635, 0.1948063 ]])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 查看数值（array）\n",
    "data.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.61373195, 0.90963794, 0.04710758],\n",
       "       [0.35881962, 0.72115783, 0.33071757],\n",
       "       [0.73142831, 0.30686638, 0.64170137],\n",
       "       [0.12687756, 0.84566761, 0.24711196],\n",
       "       [0.03227691, 0.02470314, 0.62847021],\n",
       "       [0.83758571, 0.99343088, 0.01210409],\n",
       "       [0.01818627, 0.95707384, 0.83034284],\n",
       "       [0.57395734, 0.07151762, 0.29255366],\n",
       "       [0.21670393, 0.55632854, 0.11432171],\n",
       "       [0.41538834, 0.3864216 , 0.00575529],\n",
       "       [0.94426393, 0.91708207, 0.63594728],\n",
       "       [0.91722309, 0.18756697, 0.78768256],\n",
       "       [0.6122467 , 0.24943888, 0.80112047],\n",
       "       [0.19764291, 0.85149261, 0.41622985],\n",
       "       [0.99539443, 0.68721255, 0.02363179],\n",
       "       [0.93851187, 0.15869429, 0.72826176],\n",
       "       [0.5395422 , 0.2387144 , 0.64559874],\n",
       "       [0.61933839, 0.48731224, 0.31092051],\n",
       "       [0.40568556, 0.10793083, 0.85316599],\n",
       "       [0.68179605, 0.31950728, 0.3684378 ],\n",
       "       [0.8729166 , 0.71319064, 0.05922718],\n",
       "       [0.25492159, 0.32154084, 0.3144932 ],\n",
       "       [0.27794113, 0.43711427, 0.40858835],\n",
       "       [0.73163031, 0.27818623, 0.80390927],\n",
       "       [0.50845756, 0.60040759, 0.37200829],\n",
       "       [0.20650553, 0.46758365, 0.6370221 ],\n",
       "       [0.75383435, 0.66184544, 0.14691941],\n",
       "       [0.00315055, 0.06233762, 0.37014107],\n",
       "       [0.9574998 , 0.31809475, 0.96981625],\n",
       "       [0.56591867, 0.88952635, 0.1948063 ]])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.to_numpy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>30.000000</td>\n",
       "      <td>30.000000</td>\n",
       "      <td>30.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>0.530313</td>\n",
       "      <td>0.490919</td>\n",
       "      <td>0.433270</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.307381</td>\n",
       "      <td>0.302707</td>\n",
       "      <td>0.292484</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>0.003151</td>\n",
       "      <td>0.024703</td>\n",
       "      <td>0.005755</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>0.260676</td>\n",
       "      <td>0.256626</td>\n",
       "      <td>0.207883</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>0.569938</td>\n",
       "      <td>0.452349</td>\n",
       "      <td>0.371075</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>0.748283</td>\n",
       "      <td>0.719166</td>\n",
       "      <td>0.644624</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>0.995394</td>\n",
       "      <td>0.993431</td>\n",
       "      <td>0.969816</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               A          B          C\n",
       "count  30.000000  30.000000  30.000000\n",
       "mean    0.530313   0.490919   0.433270\n",
       "std     0.307381   0.302707   0.292484\n",
       "min     0.003151   0.024703   0.005755\n",
       "25%     0.260676   0.256626   0.207883\n",
       "50%     0.569938   0.452349   0.371075\n",
       "75%     0.748283   0.719166   0.644624\n",
       "max     0.995394   0.993431   0.969816"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 查看统计摘要\n",
    "data.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2021-01-31    0.613732\n",
       "2021-02-28    0.358820\n",
       "2021-03-31    0.731428\n",
       "2021-04-30    0.126878\n",
       "2021-05-31    0.032277\n",
       "2021-06-30    0.837586\n",
       "2021-07-31    0.018186\n",
       "2021-08-31    0.573957\n",
       "2021-09-30    0.216704\n",
       "2021-10-31    0.415388\n",
       "2021-11-30    0.944264\n",
       "2021-12-31    0.917223\n",
       "2022-01-31    0.612247\n",
       "2022-02-28    0.197643\n",
       "2022-03-31    0.995394\n",
       "2022-04-30    0.938512\n",
       "2022-05-31    0.539542\n",
       "2022-06-30    0.619338\n",
       "2022-07-31    0.405686\n",
       "2022-08-31    0.681796\n",
       "2022-09-30    0.872917\n",
       "2022-10-31    0.254922\n",
       "2022-11-30    0.277941\n",
       "2022-12-31    0.731630\n",
       "2023-01-31    0.508458\n",
       "2023-02-28    0.206506\n",
       "2023-03-31    0.753834\n",
       "2023-04-30    0.003151\n",
       "2023-05-31    0.957500\n",
       "2023-06-30    0.565919\n",
       "Freq: M, Name: A, dtype: float64"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 列数据\n",
    "data['A']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-31</th>\n",
       "      <td>0.613732</td>\n",
       "      <td>0.909638</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-02-28</th>\n",
       "      <td>0.358820</td>\n",
       "      <td>0.721158</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-03-31</th>\n",
       "      <td>0.731428</td>\n",
       "      <td>0.306866</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-04-30</th>\n",
       "      <td>0.126878</td>\n",
       "      <td>0.845668</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-05-31</th>\n",
       "      <td>0.032277</td>\n",
       "      <td>0.024703</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-06-30</th>\n",
       "      <td>0.837586</td>\n",
       "      <td>0.993431</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-07-31</th>\n",
       "      <td>0.018186</td>\n",
       "      <td>0.957074</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-08-31</th>\n",
       "      <td>0.573957</td>\n",
       "      <td>0.071518</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>0.216704</td>\n",
       "      <td>0.556329</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-31</th>\n",
       "      <td>0.415388</td>\n",
       "      <td>0.386422</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-11-30</th>\n",
       "      <td>0.944264</td>\n",
       "      <td>0.917082</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-31</th>\n",
       "      <td>0.917223</td>\n",
       "      <td>0.187567</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-31</th>\n",
       "      <td>0.612247</td>\n",
       "      <td>0.249439</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-28</th>\n",
       "      <td>0.197643</td>\n",
       "      <td>0.851493</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-31</th>\n",
       "      <td>0.995394</td>\n",
       "      <td>0.687213</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-04-30</th>\n",
       "      <td>0.938512</td>\n",
       "      <td>0.158694</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-05-31</th>\n",
       "      <td>0.539542</td>\n",
       "      <td>0.238714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-06-30</th>\n",
       "      <td>0.619338</td>\n",
       "      <td>0.487312</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-07-31</th>\n",
       "      <td>0.405686</td>\n",
       "      <td>0.107931</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-31</th>\n",
       "      <td>0.681796</td>\n",
       "      <td>0.319507</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-30</th>\n",
       "      <td>0.872917</td>\n",
       "      <td>0.713191</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-31</th>\n",
       "      <td>0.254922</td>\n",
       "      <td>0.321541</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-30</th>\n",
       "      <td>0.277941</td>\n",
       "      <td>0.437114</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-31</th>\n",
       "      <td>0.731630</td>\n",
       "      <td>0.278186</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-01-31</th>\n",
       "      <td>0.508458</td>\n",
       "      <td>0.600408</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-02-28</th>\n",
       "      <td>0.206506</td>\n",
       "      <td>0.467584</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-03-31</th>\n",
       "      <td>0.753834</td>\n",
       "      <td>0.661845</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-04-30</th>\n",
       "      <td>0.003151</td>\n",
       "      <td>0.062338</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-05-31</th>\n",
       "      <td>0.957500</td>\n",
       "      <td>0.318095</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-06-30</th>\n",
       "      <td>0.565919</td>\n",
       "      <td>0.889526</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B\n",
       "2021-01-31  0.613732  0.909638\n",
       "2021-02-28  0.358820  0.721158\n",
       "2021-03-31  0.731428  0.306866\n",
       "2021-04-30  0.126878  0.845668\n",
       "2021-05-31  0.032277  0.024703\n",
       "2021-06-30  0.837586  0.993431\n",
       "2021-07-31  0.018186  0.957074\n",
       "2021-08-31  0.573957  0.071518\n",
       "2021-09-30  0.216704  0.556329\n",
       "2021-10-31  0.415388  0.386422\n",
       "2021-11-30  0.944264  0.917082\n",
       "2021-12-31  0.917223  0.187567\n",
       "2022-01-31  0.612247  0.249439\n",
       "2022-02-28  0.197643  0.851493\n",
       "2022-03-31  0.995394  0.687213\n",
       "2022-04-30  0.938512  0.158694\n",
       "2022-05-31  0.539542  0.238714\n",
       "2022-06-30  0.619338  0.487312\n",
       "2022-07-31  0.405686  0.107931\n",
       "2022-08-31  0.681796  0.319507\n",
       "2022-09-30  0.872917  0.713191\n",
       "2022-10-31  0.254922  0.321541\n",
       "2022-11-30  0.277941  0.437114\n",
       "2022-12-31  0.731630  0.278186\n",
       "2023-01-31  0.508458  0.600408\n",
       "2023-02-28  0.206506  0.467584\n",
       "2023-03-31  0.753834  0.661845\n",
       "2023-04-30  0.003151  0.062338\n",
       "2023-05-31  0.957500  0.318095\n",
       "2023-06-30  0.565919  0.889526"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[['A','B']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-31</th>\n",
       "      <td>0.613732</td>\n",
       "      <td>0.909638</td>\n",
       "      <td>0.047108</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-02-28</th>\n",
       "      <td>0.358820</td>\n",
       "      <td>0.721158</td>\n",
       "      <td>0.330718</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-03-31</th>\n",
       "      <td>0.731428</td>\n",
       "      <td>0.306866</td>\n",
       "      <td>0.641701</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-04-30</th>\n",
       "      <td>0.126878</td>\n",
       "      <td>0.845668</td>\n",
       "      <td>0.247112</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-05-31</th>\n",
       "      <td>0.032277</td>\n",
       "      <td>0.024703</td>\n",
       "      <td>0.628470</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-06-30</th>\n",
       "      <td>0.837586</td>\n",
       "      <td>0.993431</td>\n",
       "      <td>0.012104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-07-31</th>\n",
       "      <td>0.018186</td>\n",
       "      <td>0.957074</td>\n",
       "      <td>0.830343</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-08-31</th>\n",
       "      <td>0.573957</td>\n",
       "      <td>0.071518</td>\n",
       "      <td>0.292554</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>0.216704</td>\n",
       "      <td>0.556329</td>\n",
       "      <td>0.114322</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-31</th>\n",
       "      <td>0.415388</td>\n",
       "      <td>0.386422</td>\n",
       "      <td>0.005755</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C\n",
       "2021-01-31  0.613732  0.909638  0.047108\n",
       "2021-02-28  0.358820  0.721158  0.330718\n",
       "2021-03-31  0.731428  0.306866  0.641701\n",
       "2021-04-30  0.126878  0.845668  0.247112\n",
       "2021-05-31  0.032277  0.024703  0.628470\n",
       "2021-06-30  0.837586  0.993431  0.012104\n",
       "2021-07-31  0.018186  0.957074  0.830343\n",
       "2021-08-31  0.573957  0.071518  0.292554\n",
       "2021-09-30  0.216704  0.556329  0.114322\n",
       "2021-10-31  0.415388  0.386422  0.005755"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 行数据\n",
    "data[0:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-31</th>\n",
       "      <td>0.613732</td>\n",
       "      <td>0.909638</td>\n",
       "      <td>0.047108</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-02-28</th>\n",
       "      <td>0.358820</td>\n",
       "      <td>0.721158</td>\n",
       "      <td>0.330718</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-03-31</th>\n",
       "      <td>0.731428</td>\n",
       "      <td>0.306866</td>\n",
       "      <td>0.641701</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-04-30</th>\n",
       "      <td>0.126878</td>\n",
       "      <td>0.845668</td>\n",
       "      <td>0.247112</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-05-31</th>\n",
       "      <td>0.032277</td>\n",
       "      <td>0.024703</td>\n",
       "      <td>0.628470</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-06-30</th>\n",
       "      <td>0.837586</td>\n",
       "      <td>0.993431</td>\n",
       "      <td>0.012104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-07-31</th>\n",
       "      <td>0.018186</td>\n",
       "      <td>0.957074</td>\n",
       "      <td>0.830343</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-08-31</th>\n",
       "      <td>0.573957</td>\n",
       "      <td>0.071518</td>\n",
       "      <td>0.292554</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>0.216704</td>\n",
       "      <td>0.556329</td>\n",
       "      <td>0.114322</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-31</th>\n",
       "      <td>0.415388</td>\n",
       "      <td>0.386422</td>\n",
       "      <td>0.005755</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C\n",
       "2021-01-31  0.613732  0.909638  0.047108\n",
       "2021-02-28  0.358820  0.721158  0.330718\n",
       "2021-03-31  0.731428  0.306866  0.641701\n",
       "2021-04-30  0.126878  0.845668  0.247112\n",
       "2021-05-31  0.032277  0.024703  0.628470\n",
       "2021-06-30  0.837586  0.993431  0.012104\n",
       "2021-07-31  0.018186  0.957074  0.830343\n",
       "2021-08-31  0.573957  0.071518  0.292554\n",
       "2021-09-30  0.216704  0.556329  0.114322\n",
       "2021-10-31  0.415388  0.386422  0.005755"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.iloc[0:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-31</th>\n",
       "      <td>0.613732</td>\n",
       "      <td>0.909638</td>\n",
       "      <td>0.047108</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-02-28</th>\n",
       "      <td>0.358820</td>\n",
       "      <td>0.721158</td>\n",
       "      <td>0.330718</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-03-31</th>\n",
       "      <td>0.731428</td>\n",
       "      <td>0.306866</td>\n",
       "      <td>0.641701</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-04-30</th>\n",
       "      <td>0.126878</td>\n",
       "      <td>0.845668</td>\n",
       "      <td>0.247112</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-05-31</th>\n",
       "      <td>0.032277</td>\n",
       "      <td>0.024703</td>\n",
       "      <td>0.628470</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-06-30</th>\n",
       "      <td>0.837586</td>\n",
       "      <td>0.993431</td>\n",
       "      <td>0.012104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-07-31</th>\n",
       "      <td>0.018186</td>\n",
       "      <td>0.957074</td>\n",
       "      <td>0.830343</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-08-31</th>\n",
       "      <td>0.573957</td>\n",
       "      <td>0.071518</td>\n",
       "      <td>0.292554</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>0.216704</td>\n",
       "      <td>0.556329</td>\n",
       "      <td>0.114322</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-31</th>\n",
       "      <td>0.415388</td>\n",
       "      <td>0.386422</td>\n",
       "      <td>0.005755</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-11-30</th>\n",
       "      <td>0.944264</td>\n",
       "      <td>0.917082</td>\n",
       "      <td>0.635947</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-31</th>\n",
       "      <td>0.917223</td>\n",
       "      <td>0.187567</td>\n",
       "      <td>0.787683</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C\n",
       "2021-01-31  0.613732  0.909638  0.047108\n",
       "2021-02-28  0.358820  0.721158  0.330718\n",
       "2021-03-31  0.731428  0.306866  0.641701\n",
       "2021-04-30  0.126878  0.845668  0.247112\n",
       "2021-05-31  0.032277  0.024703  0.628470\n",
       "2021-06-30  0.837586  0.993431  0.012104\n",
       "2021-07-31  0.018186  0.957074  0.830343\n",
       "2021-08-31  0.573957  0.071518  0.292554\n",
       "2021-09-30  0.216704  0.556329  0.114322\n",
       "2021-10-31  0.415388  0.386422  0.005755\n",
       "2021-11-30  0.944264  0.917082  0.635947\n",
       "2021-12-31  0.917223  0.187567  0.787683"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.loc['20210101':'20220101']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-31</th>\n",
       "      <td>0.613732</td>\n",
       "      <td>0.909638</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-02-28</th>\n",
       "      <td>0.358820</td>\n",
       "      <td>0.721158</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-03-31</th>\n",
       "      <td>0.731428</td>\n",
       "      <td>0.306866</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-04-30</th>\n",
       "      <td>0.126878</td>\n",
       "      <td>0.845668</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-05-31</th>\n",
       "      <td>0.032277</td>\n",
       "      <td>0.024703</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-06-30</th>\n",
       "      <td>0.837586</td>\n",
       "      <td>0.993431</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-07-31</th>\n",
       "      <td>0.018186</td>\n",
       "      <td>0.957074</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-08-31</th>\n",
       "      <td>0.573957</td>\n",
       "      <td>0.071518</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>0.216704</td>\n",
       "      <td>0.556329</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-31</th>\n",
       "      <td>0.415388</td>\n",
       "      <td>0.386422</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-11-30</th>\n",
       "      <td>0.944264</td>\n",
       "      <td>0.917082</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-31</th>\n",
       "      <td>0.917223</td>\n",
       "      <td>0.187567</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B\n",
       "2021-01-31  0.613732  0.909638\n",
       "2021-02-28  0.358820  0.721158\n",
       "2021-03-31  0.731428  0.306866\n",
       "2021-04-30  0.126878  0.845668\n",
       "2021-05-31  0.032277  0.024703\n",
       "2021-06-30  0.837586  0.993431\n",
       "2021-07-31  0.018186  0.957074\n",
       "2021-08-31  0.573957  0.071518\n",
       "2021-09-30  0.216704  0.556329\n",
       "2021-10-31  0.415388  0.386422\n",
       "2021-11-30  0.944264  0.917082\n",
       "2021-12-31  0.917223  0.187567"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 行列切片\n",
    "data.loc['20210101':'20220101','A':'B']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 按值筛选\n",
    "data = round(data,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-31</th>\n",
       "      <td>0.61</td>\n",
       "      <td>0.91</td>\n",
       "      <td>0.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-02-28</th>\n",
       "      <td>0.36</td>\n",
       "      <td>0.72</td>\n",
       "      <td>0.33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-03-31</th>\n",
       "      <td>0.73</td>\n",
       "      <td>0.31</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-04-30</th>\n",
       "      <td>0.13</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-05-31</th>\n",
       "      <td>0.03</td>\n",
       "      <td>0.02</td>\n",
       "      <td>0.63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-06-30</th>\n",
       "      <td>0.84</td>\n",
       "      <td>0.99</td>\n",
       "      <td>0.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-07-31</th>\n",
       "      <td>0.02</td>\n",
       "      <td>0.96</td>\n",
       "      <td>0.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-08-31</th>\n",
       "      <td>0.57</td>\n",
       "      <td>0.07</td>\n",
       "      <td>0.29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>0.22</td>\n",
       "      <td>0.56</td>\n",
       "      <td>0.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-31</th>\n",
       "      <td>0.42</td>\n",
       "      <td>0.39</td>\n",
       "      <td>0.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-11-30</th>\n",
       "      <td>0.94</td>\n",
       "      <td>0.92</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-31</th>\n",
       "      <td>0.92</td>\n",
       "      <td>0.19</td>\n",
       "      <td>0.79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-31</th>\n",
       "      <td>0.61</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-28</th>\n",
       "      <td>0.20</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-31</th>\n",
       "      <td>1.00</td>\n",
       "      <td>0.69</td>\n",
       "      <td>0.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-04-30</th>\n",
       "      <td>0.94</td>\n",
       "      <td>0.16</td>\n",
       "      <td>0.73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-05-31</th>\n",
       "      <td>0.54</td>\n",
       "      <td>0.24</td>\n",
       "      <td>0.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-06-30</th>\n",
       "      <td>0.62</td>\n",
       "      <td>0.49</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-07-31</th>\n",
       "      <td>0.41</td>\n",
       "      <td>0.11</td>\n",
       "      <td>0.85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-31</th>\n",
       "      <td>0.68</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-30</th>\n",
       "      <td>0.87</td>\n",
       "      <td>0.71</td>\n",
       "      <td>0.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-31</th>\n",
       "      <td>0.25</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-30</th>\n",
       "      <td>0.28</td>\n",
       "      <td>0.44</td>\n",
       "      <td>0.41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-31</th>\n",
       "      <td>0.73</td>\n",
       "      <td>0.28</td>\n",
       "      <td>0.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-01-31</th>\n",
       "      <td>0.51</td>\n",
       "      <td>0.60</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-02-28</th>\n",
       "      <td>0.21</td>\n",
       "      <td>0.47</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-03-31</th>\n",
       "      <td>0.75</td>\n",
       "      <td>0.66</td>\n",
       "      <td>0.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-04-30</th>\n",
       "      <td>0.00</td>\n",
       "      <td>0.06</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-05-31</th>\n",
       "      <td>0.96</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-06-30</th>\n",
       "      <td>0.57</td>\n",
       "      <td>0.89</td>\n",
       "      <td>0.19</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               A     B     C\n",
       "2021-01-31  0.61  0.91  0.05\n",
       "2021-02-28  0.36  0.72  0.33\n",
       "2021-03-31  0.73  0.31  0.64\n",
       "2021-04-30  0.13  0.85  0.25\n",
       "2021-05-31  0.03  0.02  0.63\n",
       "2021-06-30  0.84  0.99  0.01\n",
       "2021-07-31  0.02  0.96  0.83\n",
       "2021-08-31  0.57  0.07  0.29\n",
       "2021-09-30  0.22  0.56  0.11\n",
       "2021-10-31  0.42  0.39  0.01\n",
       "2021-11-30  0.94  0.92  0.64\n",
       "2021-12-31  0.92  0.19  0.79\n",
       "2022-01-31  0.61  0.25  0.80\n",
       "2022-02-28  0.20  0.85  0.42\n",
       "2022-03-31  1.00  0.69  0.02\n",
       "2022-04-30  0.94  0.16  0.73\n",
       "2022-05-31  0.54  0.24  0.65\n",
       "2022-06-30  0.62  0.49  0.31\n",
       "2022-07-31  0.41  0.11  0.85\n",
       "2022-08-31  0.68  0.32  0.37\n",
       "2022-09-30  0.87  0.71  0.06\n",
       "2022-10-31  0.25  0.32  0.31\n",
       "2022-11-30  0.28  0.44  0.41\n",
       "2022-12-31  0.73  0.28  0.80\n",
       "2023-01-31  0.51  0.60  0.37\n",
       "2023-02-28  0.21  0.47  0.64\n",
       "2023-03-31  0.75  0.66  0.15\n",
       "2023-04-30  0.00  0.06  0.37\n",
       "2023-05-31  0.96  0.32  0.97\n",
       "2023-06-30  0.57  0.89  0.19"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2023-05-31</th>\n",
       "      <td>0.96</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.97</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               A     B     C\n",
       "2023-05-31  0.96  0.32  0.97"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[data['A']==0.96]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2023-05-31    0.96\n",
       "Freq: M, Name: A, dtype: float64"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[data['A']==0.96]['A']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-31</th>\n",
       "      <td>0.61</td>\n",
       "      <td>0.91</td>\n",
       "      <td>0.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-02-28</th>\n",
       "      <td>0.36</td>\n",
       "      <td>0.72</td>\n",
       "      <td>0.33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-03-31</th>\n",
       "      <td>0.73</td>\n",
       "      <td>0.31</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-04-30</th>\n",
       "      <td>0.13</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-06-30</th>\n",
       "      <td>0.84</td>\n",
       "      <td>0.99</td>\n",
       "      <td>0.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-08-31</th>\n",
       "      <td>0.57</td>\n",
       "      <td>0.07</td>\n",
       "      <td>0.29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>0.22</td>\n",
       "      <td>0.56</td>\n",
       "      <td>0.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-31</th>\n",
       "      <td>0.42</td>\n",
       "      <td>0.39</td>\n",
       "      <td>0.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-11-30</th>\n",
       "      <td>0.94</td>\n",
       "      <td>0.92</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-31</th>\n",
       "      <td>0.92</td>\n",
       "      <td>0.19</td>\n",
       "      <td>0.79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-31</th>\n",
       "      <td>0.61</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-28</th>\n",
       "      <td>0.20</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-31</th>\n",
       "      <td>1.00</td>\n",
       "      <td>0.69</td>\n",
       "      <td>0.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-04-30</th>\n",
       "      <td>0.94</td>\n",
       "      <td>0.16</td>\n",
       "      <td>0.73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-05-31</th>\n",
       "      <td>0.54</td>\n",
       "      <td>0.24</td>\n",
       "      <td>0.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-06-30</th>\n",
       "      <td>0.62</td>\n",
       "      <td>0.49</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-07-31</th>\n",
       "      <td>0.41</td>\n",
       "      <td>0.11</td>\n",
       "      <td>0.85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-31</th>\n",
       "      <td>0.68</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-30</th>\n",
       "      <td>0.87</td>\n",
       "      <td>0.71</td>\n",
       "      <td>0.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-31</th>\n",
       "      <td>0.25</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-30</th>\n",
       "      <td>0.28</td>\n",
       "      <td>0.44</td>\n",
       "      <td>0.41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-31</th>\n",
       "      <td>0.73</td>\n",
       "      <td>0.28</td>\n",
       "      <td>0.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-01-31</th>\n",
       "      <td>0.51</td>\n",
       "      <td>0.60</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-02-28</th>\n",
       "      <td>0.21</td>\n",
       "      <td>0.47</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-03-31</th>\n",
       "      <td>0.75</td>\n",
       "      <td>0.66</td>\n",
       "      <td>0.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-05-31</th>\n",
       "      <td>0.96</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-06-30</th>\n",
       "      <td>0.57</td>\n",
       "      <td>0.89</td>\n",
       "      <td>0.19</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               A     B     C\n",
       "2021-01-31  0.61  0.91  0.05\n",
       "2021-02-28  0.36  0.72  0.33\n",
       "2021-03-31  0.73  0.31  0.64\n",
       "2021-04-30  0.13  0.85  0.25\n",
       "2021-06-30  0.84  0.99  0.01\n",
       "2021-08-31  0.57  0.07  0.29\n",
       "2021-09-30  0.22  0.56  0.11\n",
       "2021-10-31  0.42  0.39  0.01\n",
       "2021-11-30  0.94  0.92  0.64\n",
       "2021-12-31  0.92  0.19  0.79\n",
       "2022-01-31  0.61  0.25  0.80\n",
       "2022-02-28  0.20  0.85  0.42\n",
       "2022-03-31  1.00  0.69  0.02\n",
       "2022-04-30  0.94  0.16  0.73\n",
       "2022-05-31  0.54  0.24  0.65\n",
       "2022-06-30  0.62  0.49  0.31\n",
       "2022-07-31  0.41  0.11  0.85\n",
       "2022-08-31  0.68  0.32  0.37\n",
       "2022-09-30  0.87  0.71  0.06\n",
       "2022-10-31  0.25  0.32  0.31\n",
       "2022-11-30  0.28  0.44  0.41\n",
       "2022-12-31  0.73  0.28  0.80\n",
       "2023-01-31  0.51  0.60  0.37\n",
       "2023-02-28  0.21  0.47  0.64\n",
       "2023-03-31  0.75  0.66  0.15\n",
       "2023-05-31  0.96  0.32  0.97\n",
       "2023-06-30  0.57  0.89  0.19"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 按条件筛选（布尔值）\n",
    "data[data['A']>0.1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-31</th>\n",
       "      <td>0.61</td>\n",
       "      <td>0.91</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-02-28</th>\n",
       "      <td>0.36</td>\n",
       "      <td>0.72</td>\n",
       "      <td>0.33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-03-31</th>\n",
       "      <td>0.73</td>\n",
       "      <td>0.31</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-04-30</th>\n",
       "      <td>0.13</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-05-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-06-30</th>\n",
       "      <td>0.84</td>\n",
       "      <td>0.99</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-07-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>0.96</td>\n",
       "      <td>0.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-08-31</th>\n",
       "      <td>0.57</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>0.22</td>\n",
       "      <td>0.56</td>\n",
       "      <td>0.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-31</th>\n",
       "      <td>0.42</td>\n",
       "      <td>0.39</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-11-30</th>\n",
       "      <td>0.94</td>\n",
       "      <td>0.92</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-31</th>\n",
       "      <td>0.92</td>\n",
       "      <td>0.19</td>\n",
       "      <td>0.79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-31</th>\n",
       "      <td>0.61</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-28</th>\n",
       "      <td>0.20</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-31</th>\n",
       "      <td>1.00</td>\n",
       "      <td>0.69</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-04-30</th>\n",
       "      <td>0.94</td>\n",
       "      <td>0.16</td>\n",
       "      <td>0.73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-05-31</th>\n",
       "      <td>0.54</td>\n",
       "      <td>0.24</td>\n",
       "      <td>0.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-06-30</th>\n",
       "      <td>0.62</td>\n",
       "      <td>0.49</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-07-31</th>\n",
       "      <td>0.41</td>\n",
       "      <td>0.11</td>\n",
       "      <td>0.85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-31</th>\n",
       "      <td>0.68</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-30</th>\n",
       "      <td>0.87</td>\n",
       "      <td>0.71</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-31</th>\n",
       "      <td>0.25</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-30</th>\n",
       "      <td>0.28</td>\n",
       "      <td>0.44</td>\n",
       "      <td>0.41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-31</th>\n",
       "      <td>0.73</td>\n",
       "      <td>0.28</td>\n",
       "      <td>0.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-01-31</th>\n",
       "      <td>0.51</td>\n",
       "      <td>0.60</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-02-28</th>\n",
       "      <td>0.21</td>\n",
       "      <td>0.47</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-03-31</th>\n",
       "      <td>0.75</td>\n",
       "      <td>0.66</td>\n",
       "      <td>0.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-04-30</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-05-31</th>\n",
       "      <td>0.96</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-06-30</th>\n",
       "      <td>0.57</td>\n",
       "      <td>0.89</td>\n",
       "      <td>0.19</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               A     B     C\n",
       "2021-01-31  0.61  0.91   NaN\n",
       "2021-02-28  0.36  0.72  0.33\n",
       "2021-03-31  0.73  0.31  0.64\n",
       "2021-04-30  0.13  0.85  0.25\n",
       "2021-05-31   NaN   NaN  0.63\n",
       "2021-06-30  0.84  0.99   NaN\n",
       "2021-07-31   NaN  0.96  0.83\n",
       "2021-08-31  0.57   NaN  0.29\n",
       "2021-09-30  0.22  0.56  0.11\n",
       "2021-10-31  0.42  0.39   NaN\n",
       "2021-11-30  0.94  0.92  0.64\n",
       "2021-12-31  0.92  0.19  0.79\n",
       "2022-01-31  0.61  0.25  0.80\n",
       "2022-02-28  0.20  0.85  0.42\n",
       "2022-03-31  1.00  0.69   NaN\n",
       "2022-04-30  0.94  0.16  0.73\n",
       "2022-05-31  0.54  0.24  0.65\n",
       "2022-06-30  0.62  0.49  0.31\n",
       "2022-07-31  0.41  0.11  0.85\n",
       "2022-08-31  0.68  0.32  0.37\n",
       "2022-09-30  0.87  0.71   NaN\n",
       "2022-10-31  0.25  0.32  0.31\n",
       "2022-11-30  0.28  0.44  0.41\n",
       "2022-12-31  0.73  0.28  0.80\n",
       "2023-01-31  0.51  0.60  0.37\n",
       "2023-02-28  0.21  0.47  0.64\n",
       "2023-03-31  0.75  0.66  0.15\n",
       "2023-04-30   NaN   NaN  0.37\n",
       "2023-05-31  0.96  0.32  0.97\n",
       "2023-06-30  0.57  0.89  0.19"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = data[data>0.1]\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-02-28</th>\n",
       "      <td>0.36</td>\n",
       "      <td>0.72</td>\n",
       "      <td>0.33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-03-31</th>\n",
       "      <td>0.73</td>\n",
       "      <td>0.31</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-04-30</th>\n",
       "      <td>0.13</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>0.22</td>\n",
       "      <td>0.56</td>\n",
       "      <td>0.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-11-30</th>\n",
       "      <td>0.94</td>\n",
       "      <td>0.92</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-31</th>\n",
       "      <td>0.92</td>\n",
       "      <td>0.19</td>\n",
       "      <td>0.79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-31</th>\n",
       "      <td>0.61</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-28</th>\n",
       "      <td>0.20</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-04-30</th>\n",
       "      <td>0.94</td>\n",
       "      <td>0.16</td>\n",
       "      <td>0.73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-05-31</th>\n",
       "      <td>0.54</td>\n",
       "      <td>0.24</td>\n",
       "      <td>0.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-06-30</th>\n",
       "      <td>0.62</td>\n",
       "      <td>0.49</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-07-31</th>\n",
       "      <td>0.41</td>\n",
       "      <td>0.11</td>\n",
       "      <td>0.85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-31</th>\n",
       "      <td>0.68</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-31</th>\n",
       "      <td>0.25</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-30</th>\n",
       "      <td>0.28</td>\n",
       "      <td>0.44</td>\n",
       "      <td>0.41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-31</th>\n",
       "      <td>0.73</td>\n",
       "      <td>0.28</td>\n",
       "      <td>0.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-01-31</th>\n",
       "      <td>0.51</td>\n",
       "      <td>0.60</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-02-28</th>\n",
       "      <td>0.21</td>\n",
       "      <td>0.47</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-03-31</th>\n",
       "      <td>0.75</td>\n",
       "      <td>0.66</td>\n",
       "      <td>0.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-05-31</th>\n",
       "      <td>0.96</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-06-30</th>\n",
       "      <td>0.57</td>\n",
       "      <td>0.89</td>\n",
       "      <td>0.19</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               A     B     C\n",
       "2021-02-28  0.36  0.72  0.33\n",
       "2021-03-31  0.73  0.31  0.64\n",
       "2021-04-30  0.13  0.85  0.25\n",
       "2021-09-30  0.22  0.56  0.11\n",
       "2021-11-30  0.94  0.92  0.64\n",
       "2021-12-31  0.92  0.19  0.79\n",
       "2022-01-31  0.61  0.25  0.80\n",
       "2022-02-28  0.20  0.85  0.42\n",
       "2022-04-30  0.94  0.16  0.73\n",
       "2022-05-31  0.54  0.24  0.65\n",
       "2022-06-30  0.62  0.49  0.31\n",
       "2022-07-31  0.41  0.11  0.85\n",
       "2022-08-31  0.68  0.32  0.37\n",
       "2022-10-31  0.25  0.32  0.31\n",
       "2022-11-30  0.28  0.44  0.41\n",
       "2022-12-31  0.73  0.28  0.80\n",
       "2023-01-31  0.51  0.60  0.37\n",
       "2023-02-28  0.21  0.47  0.64\n",
       "2023-03-31  0.75  0.66  0.15\n",
       "2023-05-31  0.96  0.32  0.97\n",
       "2023-06-30  0.57  0.89  0.19"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 去缺失值\n",
    "data.dropna()\n",
    "# data.drop_duplicates()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2021-01-31</th>\n",
       "      <th>2021-02-28</th>\n",
       "      <th>2021-03-31</th>\n",
       "      <th>2021-04-30</th>\n",
       "      <th>2021-05-31</th>\n",
       "      <th>2021-06-30</th>\n",
       "      <th>2021-07-31</th>\n",
       "      <th>2021-08-31</th>\n",
       "      <th>2021-09-30</th>\n",
       "      <th>2021-10-31</th>\n",
       "      <th>...</th>\n",
       "      <th>2022-09-30</th>\n",
       "      <th>2022-10-31</th>\n",
       "      <th>2022-11-30</th>\n",
       "      <th>2022-12-31</th>\n",
       "      <th>2023-01-31</th>\n",
       "      <th>2023-02-28</th>\n",
       "      <th>2023-03-31</th>\n",
       "      <th>2023-04-30</th>\n",
       "      <th>2023-05-31</th>\n",
       "      <th>2023-06-30</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>0.61</td>\n",
       "      <td>0.36</td>\n",
       "      <td>0.73</td>\n",
       "      <td>0.13</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.84</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.57</td>\n",
       "      <td>0.22</td>\n",
       "      <td>0.42</td>\n",
       "      <td>...</td>\n",
       "      <td>0.87</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.28</td>\n",
       "      <td>0.73</td>\n",
       "      <td>0.51</td>\n",
       "      <td>0.21</td>\n",
       "      <td>0.75</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.96</td>\n",
       "      <td>0.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>0.91</td>\n",
       "      <td>0.72</td>\n",
       "      <td>0.31</td>\n",
       "      <td>0.85</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.99</td>\n",
       "      <td>0.96</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.56</td>\n",
       "      <td>0.39</td>\n",
       "      <td>...</td>\n",
       "      <td>0.71</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.44</td>\n",
       "      <td>0.28</td>\n",
       "      <td>0.60</td>\n",
       "      <td>0.47</td>\n",
       "      <td>0.66</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>NaN</td>\n",
       "      <td>0.33</td>\n",
       "      <td>0.64</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.63</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.83</td>\n",
       "      <td>0.29</td>\n",
       "      <td>0.11</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.31</td>\n",
       "      <td>0.41</td>\n",
       "      <td>0.80</td>\n",
       "      <td>0.37</td>\n",
       "      <td>0.64</td>\n",
       "      <td>0.15</td>\n",
       "      <td>0.37</td>\n",
       "      <td>0.97</td>\n",
       "      <td>0.19</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3 rows × 30 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   2021-01-31  2021-02-28  2021-03-31  2021-04-30  2021-05-31  2021-06-30  \\\n",
       "A        0.61        0.36        0.73        0.13         NaN        0.84   \n",
       "B        0.91        0.72        0.31        0.85         NaN        0.99   \n",
       "C         NaN        0.33        0.64        0.25        0.63         NaN   \n",
       "\n",
       "   2021-07-31  2021-08-31  2021-09-30  2021-10-31  ...  2022-09-30  \\\n",
       "A         NaN        0.57        0.22        0.42  ...        0.87   \n",
       "B        0.96         NaN        0.56        0.39  ...        0.71   \n",
       "C        0.83        0.29        0.11         NaN  ...         NaN   \n",
       "\n",
       "   2022-10-31  2022-11-30  2022-12-31  2023-01-31  2023-02-28  2023-03-31  \\\n",
       "A        0.25        0.28        0.73        0.51        0.21        0.75   \n",
       "B        0.32        0.44        0.28        0.60        0.47        0.66   \n",
       "C        0.31        0.41        0.80        0.37        0.64        0.15   \n",
       "\n",
       "   2023-04-30  2023-05-31  2023-06-30  \n",
       "A         NaN        0.96        0.57  \n",
       "B         NaN        0.32        0.89  \n",
       "C        0.37        0.97        0.19  \n",
       "\n",
       "[3 rows x 30 columns]"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 其他：转置、排序\n",
    "data.T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "data.sort_values?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2022-03-31</th>\n",
       "      <td>1.00</td>\n",
       "      <td>0.69</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-05-31</th>\n",
       "      <td>0.96</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-04-30</th>\n",
       "      <td>0.94</td>\n",
       "      <td>0.16</td>\n",
       "      <td>0.73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-11-30</th>\n",
       "      <td>0.94</td>\n",
       "      <td>0.92</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-31</th>\n",
       "      <td>0.92</td>\n",
       "      <td>0.19</td>\n",
       "      <td>0.79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-30</th>\n",
       "      <td>0.87</td>\n",
       "      <td>0.71</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-06-30</th>\n",
       "      <td>0.84</td>\n",
       "      <td>0.99</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-03-31</th>\n",
       "      <td>0.75</td>\n",
       "      <td>0.66</td>\n",
       "      <td>0.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-03-31</th>\n",
       "      <td>0.73</td>\n",
       "      <td>0.31</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-31</th>\n",
       "      <td>0.73</td>\n",
       "      <td>0.28</td>\n",
       "      <td>0.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-31</th>\n",
       "      <td>0.68</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-06-30</th>\n",
       "      <td>0.62</td>\n",
       "      <td>0.49</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-31</th>\n",
       "      <td>0.61</td>\n",
       "      <td>0.91</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-31</th>\n",
       "      <td>0.61</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-08-31</th>\n",
       "      <td>0.57</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-06-30</th>\n",
       "      <td>0.57</td>\n",
       "      <td>0.89</td>\n",
       "      <td>0.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-05-31</th>\n",
       "      <td>0.54</td>\n",
       "      <td>0.24</td>\n",
       "      <td>0.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-01-31</th>\n",
       "      <td>0.51</td>\n",
       "      <td>0.60</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-31</th>\n",
       "      <td>0.42</td>\n",
       "      <td>0.39</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-07-31</th>\n",
       "      <td>0.41</td>\n",
       "      <td>0.11</td>\n",
       "      <td>0.85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-02-28</th>\n",
       "      <td>0.36</td>\n",
       "      <td>0.72</td>\n",
       "      <td>0.33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-30</th>\n",
       "      <td>0.28</td>\n",
       "      <td>0.44</td>\n",
       "      <td>0.41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-31</th>\n",
       "      <td>0.25</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>0.22</td>\n",
       "      <td>0.56</td>\n",
       "      <td>0.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-02-28</th>\n",
       "      <td>0.21</td>\n",
       "      <td>0.47</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-28</th>\n",
       "      <td>0.20</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-04-30</th>\n",
       "      <td>0.13</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-05-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-07-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>0.96</td>\n",
       "      <td>0.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-04-30</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               A     B     C\n",
       "2022-03-31  1.00  0.69   NaN\n",
       "2023-05-31  0.96  0.32  0.97\n",
       "2022-04-30  0.94  0.16  0.73\n",
       "2021-11-30  0.94  0.92  0.64\n",
       "2021-12-31  0.92  0.19  0.79\n",
       "2022-09-30  0.87  0.71   NaN\n",
       "2021-06-30  0.84  0.99   NaN\n",
       "2023-03-31  0.75  0.66  0.15\n",
       "2021-03-31  0.73  0.31  0.64\n",
       "2022-12-31  0.73  0.28  0.80\n",
       "2022-08-31  0.68  0.32  0.37\n",
       "2022-06-30  0.62  0.49  0.31\n",
       "2021-01-31  0.61  0.91   NaN\n",
       "2022-01-31  0.61  0.25  0.80\n",
       "2021-08-31  0.57   NaN  0.29\n",
       "2023-06-30  0.57  0.89  0.19\n",
       "2022-05-31  0.54  0.24  0.65\n",
       "2023-01-31  0.51  0.60  0.37\n",
       "2021-10-31  0.42  0.39   NaN\n",
       "2022-07-31  0.41  0.11  0.85\n",
       "2021-02-28  0.36  0.72  0.33\n",
       "2022-11-30  0.28  0.44  0.41\n",
       "2022-10-31  0.25  0.32  0.31\n",
       "2021-09-30  0.22  0.56  0.11\n",
       "2023-02-28  0.21  0.47  0.64\n",
       "2022-02-28  0.20  0.85  0.42\n",
       "2021-04-30  0.13  0.85  0.25\n",
       "2021-05-31   NaN   NaN  0.63\n",
       "2021-07-31   NaN  0.96  0.83\n",
       "2023-04-30   NaN   NaN  0.37"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.sort_values(by='A',ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2023-06-30</th>\n",
       "      <td>0.57</td>\n",
       "      <td>0.89</td>\n",
       "      <td>0.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-05-31</th>\n",
       "      <td>0.96</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-04-30</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-03-31</th>\n",
       "      <td>0.75</td>\n",
       "      <td>0.66</td>\n",
       "      <td>0.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-02-28</th>\n",
       "      <td>0.21</td>\n",
       "      <td>0.47</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-01-31</th>\n",
       "      <td>0.51</td>\n",
       "      <td>0.60</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-12-31</th>\n",
       "      <td>0.73</td>\n",
       "      <td>0.28</td>\n",
       "      <td>0.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-11-30</th>\n",
       "      <td>0.28</td>\n",
       "      <td>0.44</td>\n",
       "      <td>0.41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-10-31</th>\n",
       "      <td>0.25</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-09-30</th>\n",
       "      <td>0.87</td>\n",
       "      <td>0.71</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-08-31</th>\n",
       "      <td>0.68</td>\n",
       "      <td>0.32</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-07-31</th>\n",
       "      <td>0.41</td>\n",
       "      <td>0.11</td>\n",
       "      <td>0.85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-06-30</th>\n",
       "      <td>0.62</td>\n",
       "      <td>0.49</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-05-31</th>\n",
       "      <td>0.54</td>\n",
       "      <td>0.24</td>\n",
       "      <td>0.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-04-30</th>\n",
       "      <td>0.94</td>\n",
       "      <td>0.16</td>\n",
       "      <td>0.73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-03-31</th>\n",
       "      <td>1.00</td>\n",
       "      <td>0.69</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-02-28</th>\n",
       "      <td>0.20</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022-01-31</th>\n",
       "      <td>0.61</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-31</th>\n",
       "      <td>0.92</td>\n",
       "      <td>0.19</td>\n",
       "      <td>0.79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-11-30</th>\n",
       "      <td>0.94</td>\n",
       "      <td>0.92</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-10-31</th>\n",
       "      <td>0.42</td>\n",
       "      <td>0.39</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>0.22</td>\n",
       "      <td>0.56</td>\n",
       "      <td>0.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-08-31</th>\n",
       "      <td>0.57</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-07-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>0.96</td>\n",
       "      <td>0.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-06-30</th>\n",
       "      <td>0.84</td>\n",
       "      <td>0.99</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-05-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-04-30</th>\n",
       "      <td>0.13</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-03-31</th>\n",
       "      <td>0.73</td>\n",
       "      <td>0.31</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-02-28</th>\n",
       "      <td>0.36</td>\n",
       "      <td>0.72</td>\n",
       "      <td>0.33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-31</th>\n",
       "      <td>0.61</td>\n",
       "      <td>0.91</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               A     B     C\n",
       "2023-06-30  0.57  0.89  0.19\n",
       "2023-05-31  0.96  0.32  0.97\n",
       "2023-04-30   NaN   NaN  0.37\n",
       "2023-03-31  0.75  0.66  0.15\n",
       "2023-02-28  0.21  0.47  0.64\n",
       "2023-01-31  0.51  0.60  0.37\n",
       "2022-12-31  0.73  0.28  0.80\n",
       "2022-11-30  0.28  0.44  0.41\n",
       "2022-10-31  0.25  0.32  0.31\n",
       "2022-09-30  0.87  0.71   NaN\n",
       "2022-08-31  0.68  0.32  0.37\n",
       "2022-07-31  0.41  0.11  0.85\n",
       "2022-06-30  0.62  0.49  0.31\n",
       "2022-05-31  0.54  0.24  0.65\n",
       "2022-04-30  0.94  0.16  0.73\n",
       "2022-03-31  1.00  0.69   NaN\n",
       "2022-02-28  0.20  0.85  0.42\n",
       "2022-01-31  0.61  0.25  0.80\n",
       "2021-12-31  0.92  0.19  0.79\n",
       "2021-11-30  0.94  0.92  0.64\n",
       "2021-10-31  0.42  0.39   NaN\n",
       "2021-09-30  0.22  0.56  0.11\n",
       "2021-08-31  0.57   NaN  0.29\n",
       "2021-07-31   NaN  0.96  0.83\n",
       "2021-06-30  0.84  0.99   NaN\n",
       "2021-05-31   NaN   NaN  0.63\n",
       "2021-04-30  0.13  0.85  0.25\n",
       "2021-03-31  0.73  0.31  0.64\n",
       "2021-02-28  0.36  0.72  0.33\n",
       "2021-01-31  0.61  0.91   NaN"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.sort_index(ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
